package com.stevenmoon.csdnplus.app;

import android.app.Application;

import com.orhanobut.logger.AndroidLogTool;
import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;


/**自定义Application
 * Created by WangJun on 2016/3/27.
 */
public class GlobalContext extends Application {

    public static final String DEFAULT_TAG = "YISIZHU";

    private RefWatcher refWatcher;

    private static GlobalContext sInstance;

    public static GlobalContext getInstance(){
        return sInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;
        //Timber.plant(new Timber.DebugTree());
        refWatcher = LeakCanary.install(this);
        //BlockCanary.install(this, new AppBlockCanaryContext()).start();
        initLogger();
    }

    private void initLogger(){
        Logger
                .init(DEFAULT_TAG)                 // default PRETTYLOGGER or use just init()
                .methodCount(4)                 // default 2
                .hideThreadInfo()               // default shown
                .logLevel(LogLevel.FULL)        // default LogLevel.FULL
                .methodOffset(4)                // default 0
                .logTool(new AndroidLogTool()); // custom log tool, optional
    }


    public  RefWatcher getRefWatcher() {
        return sInstance.refWatcher;
    }


}
